#ifndef _SERIAL_CONTROL_
#define _SERIAL_CONTROL_
#include "serial_build.h"
// #include "basis_state.h"
// #include "coupling_coeff.h"
// //#include "trans_coeff.h"
// #include "wavefun_coeff.h"
// //#include "cont_term.h"
// #include "tpe_term.h"
// #include "com_sparse_row.h"
#include <string>
#include <iostream>
#include <fstream>
using std::string;



class Serial_SL{
  // serial control Save & Load
 public:
   //~~~~~~~~~~~~~~~~~~~For com_sparse_row.h save~~~~~~~~~~~~~~~~~~~~~~~~~//
   void save(SMatrix &A, string filename){
     std::ofstream ofs(filename);
     // save data to archive
     boost::archive::binary_oarchive oa(ofs);
     // write class instance to archive
     oa << A;
   }
   void save(SMatrix_Ch &A, string filename){
     std::ofstream ofs(filename);
     // save data to archive
     boost::archive::binary_oarchive oa(ofs);
     // write class instance to archive
     oa << A;
   }
  //~~~~~~~~~~~~~~~~~~~For coupling_coeff.h save~~~~~~~~~~~~~~~~~~~~~~~~~//
  void save(CG_coeff &cg, string filename){
    std::ofstream ofs(filename);
    // save data to archive
    boost::archive::binary_oarchive oa(ofs);
    // write class instance to archive
    oa << cg;
  }
  void save(SixJ_coeff &sixJ, string filename){
    std::ofstream ofs(filename);
    // save data to archive
    boost::archive::binary_oarchive oa(ofs);
    // write class instance to archive
    oa << sixJ;
  }
  void save(NinJ_coeff &nineJ, string filename){
    std::ofstream ofs(filename);
    // save data to archive
    boost::archive::binary_oarchive oa(ofs);
    // write class instance to archive
    oa << nineJ;
  }
  void save(Binom &bin, string filename){
    std::ofstream ofs(filename);
    // save data to archive
    boost::archive::binary_oarchive oa(ofs);
    // write class instance to archive
    oa << bin;
  }

  //~~~~~~~~~~~~~~~~~~~For basis_state.h save~~~~~~~~~~~~~~~~~~~~~~~~~//
  void save(Jacobi &jaco, string filename){
    std::ofstream ofs(filename);
    // save data to archive
    boost::archive::binary_oarchive oa(ofs);
    // write class instance to archive
    oa << jaco;
  }
  void save(Jacobi_NL &jaco_nl, string filename){
    std::ofstream ofs(filename);
    // save data to archive
    boost::archive::binary_oarchive oa(ofs);
    // write class instance to archive
    oa << jaco_nl;
  }
  void save(SingleP &SP, string filename){
    std::ofstream ofs(filename);
    // save data to archive
    boost::archive::binary_oarchive oa(ofs);
    // write class instance to archive
    oa << SP;
  }
  void save(TripleP &TP, string filename){
    std::ofstream ofs(filename);
    // save data to archive
    boost::archive::binary_oarchive oa(ofs);
    // write class instance to archive
    oa << TP;
  }
  //~~~~~~~~~~~~~~~~~~~~~~~~For antisymmetry and T ~~~~~~~~~~~~~~~~//
  void save(Antisym &ant, string filename){
    std::ofstream ofs(filename);
    // save data to archive
    boost::archive::binary_oarchive oa(ofs);
    // write class instance to archive
    oa << ant;
  }
  void save(TransCoeff &T, string filename){
    std::ofstream ofs(filename);
    // save data to archive
    boost::archive::binary_oarchive oa(ofs);
    // write class instance to archive
    oa << T;
  }
  //~~~~~~~~~~~~~~~~~~~~~~~~For Wave_Fun    save ~~~~~~~~~~~~~~~~//
  void save(Wave_Fun &w, string filename){
    std::ofstream ofs(filename);
    // save data to archive
    boost::archive::binary_oarchive oa(ofs);
    // write class instance to archive
    oa << w;
  }
  //~~~~~~~~~~~~~~~~~~~~~~~~For Contact term save ~~~~~~~~~~~~~~~~//
  void save(Cont_term &C, string filename){
    std::ofstream ofs(filename);
    // save data to archive
    boost::archive::binary_oarchive oa(ofs);
    // write class instance to archive
    oa << C;
  }
  //~~~~~~~~~~~~~~~~~~~~~~~~For Contact term save ~~~~~~~~~~~~~~~~//
  void save(Ope_term &O, string filename){
    std::ofstream ofs(filename);
    // save data to archive
    boost::archive::binary_oarchive oa(ofs);
    // write class instance to archive
    oa << O;
  }
  //~~~~~~~~~~~~~~~~~~~~~~~~For Tpe term save ~~~~~~~~~~~~~~~~//
  void save(Tpe_term &T, string filename){
    std::ofstream ofs(filename);
    // save data to archive
    boost::archive::binary_oarchive oa(ofs);
    // write class instance to archive
    oa << T;
  }
  //~~~~~~~~~~~~~~~~~~~~~~~~For Package save ~~~~~~~~~~~~~~~~//
  void save(Package &P, string filename){
    std::ofstream ofs(filename);
    // save data to archive
    boost::archive::binary_oarchive oa(ofs);
    // write class instance to archive
    oa << P;
  }





  //~~~~~~~~~~~~~~~~~~~For com_sparse_row.h load~~~~~~~~~~~~~~~~~~~~~~~~~//
  void load(SMatrix &A, string filename){
    std::ifstream ifs(filename);
    // save data to archive
    boost::archive::binary_iarchive ia(ifs);
    // write class instance to archive
    ia >> A;
  }
  void load(SMatrix_Ch &A, string filename){
    std::ifstream ifs(filename);
    // save data to archive
    boost::archive::binary_iarchive ia(ifs);
    // write class instance to archive
    ia >> A;
  }
  //~~~~~~~~~~~~~~~~~~~For coupling_coeff.h load~~~~~~~~~~~~~~~~~~~~~~~~~//
  void load(CG_coeff &cg, string filename){
    std::ifstream ifs(filename);
    // save data to archive
    boost::archive::binary_iarchive ia(ifs);
    // write class instance to archive
    ia >> cg;
  }
  void load(SixJ_coeff &sixJ, string filename){
    std::ifstream ifs(filename);
    // save data to archive
    boost::archive::binary_iarchive ia(ifs);
    // write class instance to archive
    ia >> sixJ;
  }
  void load(NinJ_coeff &nineJ, string filename){
    std::ifstream ifs(filename);
    // save data to archive
    boost::archive::binary_iarchive ia(ifs);
    // write class instance to archive
    ia >> nineJ;
  }
  void load(Binom &bin, string filename){
    std::ifstream ifs(filename);
    // save data to archive
    boost::archive::binary_iarchive ia(ifs);
    // write class instance to archive
    ia >> bin;
  }

  //~~~~~~~~~~~~~~~~~~~For basis_state.h load~~~~~~~~~~~~~~~~~~~~~~~~~//
  void load(Jacobi &jaco, string filename){
    std::ifstream ifs(filename);
    // save data to archive
    boost::archive::binary_iarchive ia(ifs);
    // write class instance to archive
    ia >> jaco;
  }
  void load(Jacobi_NL &jaco_nl, string filename){
    std::ifstream ifs(filename);
    // save data to archive
    boost::archive::binary_iarchive ia(ifs);
    // write class instance to archive
    ia >> jaco_nl;
  }
  void load(SingleP &SP, string filename){
    std::ifstream ifs(filename);
    // save data to archive
    boost::archive::binary_iarchive ia(ifs);
    // write class instance to archive
    ia >> SP;
  }
  void load(TripleP &TP, string filename){
    std::ifstream ifs(filename);
    // save data to archive
    boost::archive::binary_iarchive ia(ifs);
    // write class instance to archive
    ia >> TP;
  }
  //~~~~~~~~~~~~~~~~~~For antisymmetry and T~~~~~~~~~~~~~~~~~~~~~~~~~~~//
  void load(Antisym &ant, string filename){
    std::ifstream ifs(filename);
    // save data to archive
    boost::archive::binary_iarchive ia(ifs);
    // write class instance to archive
    ia >> ant;
  }
  void load(TransCoeff &T, string filename){
    std::ifstream ifs(filename);
    // save data to archive
    boost::archive::binary_iarchive ia(ifs);
    // write class instance to archive
    ia >> T;
  }
  //~~~~~~~~~~~~~~~~~~For Wave Function~~~~~~~~~~~~~~~~~~~~~~~~~~~//
  void load(Wave_Fun &w, string filename){
    std::ifstream ifs(filename);
    // save data to archive
    boost::archive::binary_iarchive ia(ifs);
    // write class instance to archive
    ia >> w;
  }
  //~~~~~~~~~~~~~~~~~~For Contact term ~~~~~~~~~~~~~~~~~~~~~~~~~~~//
  void load(Cont_term &C, string filename){
    std::ifstream ifs(filename);
    // save data to archive
    boost::archive::binary_iarchive ia(ifs);
    // write class instance to archive
    ia >> C;
  }
  void load(Ope_term &O, string filename){
    std::ifstream ifs(filename);
    // save data to archive
    boost::archive::binary_iarchive ia(ifs);
    // write class instance to archive
    ia >> O;
  }

  //~~~~~~~~~~~~~~~~~~For TPE term ~~~~~~~~~~~~~~~~~~~~~~~~~~~//
  void load(Tpe_term &T, string filename){
    std::ifstream ifs(filename);
    // save data to archive
    boost::archive::binary_iarchive ia(ifs);
    // write class instance to archive
    ia >> T;
  }

  //~~~~~~~~~~~~~~~~~~For Package term ~~~~~~~~~~~~~~~~~~~~~~~~~~~//
  void load(Package &P, string filename){
    std::ifstream ifs(filename);
    // save data to archive
    boost::archive::binary_iarchive ia(ifs);
    // write class instance to archive
    ia >> P;
  }

};






#endif
